#!/bin/bash

echo "🔧 修复容器 Nginx 配置..."

# 复制修复后的 Nginx 配置到容器
echo "📋 复制 Nginx 配置..."
docker cp nginx-fixed.conf sse-coding-server-frontend-1:/etc/nginx/conf.d/default.conf

# 复制测试文件到容器
echo "📄 复制测试文件..."
docker cp test-routes.html sse-coding-server-frontend-1:/usr/share/nginx/html/

# 测试 Nginx 配置
echo "🧪 测试 Nginx 配置..."
docker exec sse-coding-server-frontend-1 nginx -t

if [ $? -eq 0 ]; then
    # 重新加载 Nginx 配置
    echo "🔄 重新加载 Nginx..."
    docker exec sse-coding-server-frontend-1 nginx -s reload
    
    echo "✅ 配置已更新！"
    echo "🌐 现在可以测试："
    echo "   - http://47.106.88.20/"
    echo "   - http://47.106.88.20/questions"
    echo "   - http://47.106.88.20/test-routes.html"
else
    echo "❌ Nginx 配置测试失败"
    exit 1
fi

